<?php
class Zen_Exception extends Exception
{
    protected $_class;

    protected $_info = array();

    public function __construct($config = null)
    {
        $default = array(
            'class' => '',
            'code'  => '',
            'text'  => '',
            'info'  => array(),
        );
        $config = array_merge($default, (array) $config);

        parent::__construct($config['text']);
        $this->code = $config['code'];
        $this->_class = $config['class'];
        $this->_info = (array) $config['info'];
    }

    public function __toString()
    {
        $class_code = $this->_class . "::" . $this->code;

        // basic string
        $str = "exception '" . get_class($this) . "'\n"
             . "class::code '$class_code' \n"
             . "with message '" . $this->message . "' \n"
             . "information " . var_export($this->_info, true) . " \n";
        // done
        return $str;
    }
}